# -*- coding: utf-8 -*-
# 读写2003 excel
import xlrd
import re
workbook = xlrd.open_workbook("F:\\无标题.xls")
table=workbook.sheet_by_name('Sheet1')

nrows=table.nrows
for i in range(nrows):
  csql="update resource_chapter set "
  row = table.row_values(i)
  if i<1:
    print("-- ----------Sheet1-")
  else:
    j=0;
    resource_id ='';
    audio_url ='';
    chapter_title='';
    for cell in row:
      cell=str(cell).replace("\n", "").replace("\r","").replace("\u200B","").replace("http://resource.helloprincess62.top","").replace(".aac","").replace("resource","local").strip()
      if j==0:
        resource_id=cell;
      if j==2:
        chapter_title=cell;
      if j==3:
        audio_url =  cell; 
      j=j+1;
    if(len(resource_id)>0 and len(audio_url)>0 and len(chapter_title)>0):
      audio_url = audio_url if(audio_url.find(".")>0) else audio_url+".mp3"
      print(csql +" `audio_url` ='"+audio_url+ "' where `chapter_title` = '"+chapter_title+"' and `resource_id`= '"+resource_id+"';")
  i=i+1

